<template>
  <div class="app-container">
      <div class="time">
        <span>医嘱时间:</span>
        <el-date-picker
          v-model="enterStartTime"
          align="right"
          :clearable="false"
          type="date"
          format="yyyy-MM-dd"
          value-format="yyyy-MM-dd"
        />
      </div>
      <el-button type="primary" icon="el-icon-search" class="Btn" @click="btn"
        >检索</el-button
      >
      <el-table
        :data="dataArray"
        style="width: 100%"
        height="488"
        stripe
        :header-cell-style="{ background: '#d2e0f9', color: '#606266' }"
        ref="multipleTable"
      >
        <el-table-column type="index" label="序号" />
        <el-table-column label="id" align="center" prop="id" v-if="false" />
        <el-table-column
          prop="order_name"
          label="药物内容	"
          align="center"
        />
        <el-table-column
          prop="address"
          label="操作"
          align="center"
        >
        <template slot-scope="scope">
          <el-button
            size="mini"
            @click="handleEdit(scope.row)"
          >选择</el-button>
        </template>
        </el-table-column>
      </el-table>
      <div class="paging">
        <el-pagination
          :current-page="start"
          :page-size="PageSize"
          :pager-count="5"
          layout="total, sizes, prev, pager, next, jumper"
          :total="totalCount"
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
        />
      </div>
  </div>
</template>

<script>
import {
  medOrderExecSynchronousInPut,
  medOrderExecSynchronousInPutS,
  medOrderExecSynchronousNursingRecord,
  getCodeListByName,
  getUserListByUserType,
  medOrderExecgetSonOrderList,
  getCustomFieldListqueryVitalSignData,
} from "@/api/table";

export default {
    props: {
    rowIndex:Number,
  },
  data() {
    return {
      arrListgeiyao: [],
      arrListru: [],
      arrName: [],
      dataArray: [],
      synInputShow: false,
      synNursingRecordShow: false,
      tableData: [],
      data: {},
      start: 1, // 默认显示第几页
      totalCount: 0, // 总条数，根据接口获取数据长度(注意：这里不能为空)
      pgeSizes: [10, 20, 30, 40], // 个数选择器（可修改）
      PageSize: 10, // 默认每页显示的条数（可修改）
      aaa: {
        drugType: "",
        repeatIndicator: "",
        orderStatus: "",
      },
      patientId: "",
      enterStartTime: "",
    };
  },
  computed: {
    getData() {
      return this.$store.state.user.severFall;
    },
  },
  watch: {
    getData() {
      console.log(this.enterStartTime,"7777777")
      this.data = this.$store.state.user.severFall;
      if (
        typeof this.data.patient_id == "string" &&
        this.data.patient_id.length > 0
      ) {
        this.enterStartTime=this.getFullDate();
        this.patientId = this.data.patient_id;
        this.queryInOut(this.PageSize, this.start);
      } else {
        this.$message({
          message: "请先选择病人",
          type: "warning",
        });
      }
    },
  },
  mounted() {
    console.log(this.enterStartTime,"88888888")
    this.data = this.$store.state.user.severFall;
    if (
      typeof this.data.patient_id == "string" &&
      this.data.patient_id.length > 0
    ) {
      this.enterStartTime=this.getFullDate();
      this.patientId = this.data.patient_id;
      this.queryInOut(this.PageSize, this.start);
    } else {
      this.$message({
        message: "请先选择病人",
        type: "warning",
      });
    }
  },
  methods: {

      //获取当前时间
    getFullDate() {
      var date=new Date();
      var str = "" + date.getFullYear();

      if (date.getMonth() < 9) str += "-0" + (date.getMonth() + 1);
      else str += "-" + (date.getMonth() + 1);

      if (date.getDate() < 10) str += "-0" + date.getDate();
      else str += "-" + date.getDate();

      return str;
    },
    //查询数据
    queryInOut(pageSize, start) {
      console.log(this.enterStartTime)
      getCustomFieldListqueryVitalSignData({
        status: 1,
        patientId: this.data.patient_id,
        vitalSignTime: this.enterStartTime,
        size: pageSize,
        start: start,
      }).then((res) => {
        console.log(res.data)
        if (res.data!=null && res.data.length>0) {
          this.dataArray = res.data;
          this.totalCount = res.totalCount
        }
      });
    },
    //选择
    handleEdit(info) {
       var item = new Object();
       item.rowIndex = this.rowIndex;
       item.val = info.order_name;
       console.log(item,'飞狗')
       eventBus.$emit('selectTemshuijiaoba', item);
    },
    //检索
    btn() {
      console.log(this.PageSize, this.start)
      this.queryInOut(this.PageSize, this.start);
    },
    // 每页显示的条数
    handleSizeChange(val) {
      // 改变每页显示的条数
      this.PageSize = val;
      // 点击每页显示的条数时，显示第一页
      this.queryInOut(val, 1);
      // 注意：在改变每页显示的条数时，要将页码显示到第一页
      this.start = 1;
    },
    // 显示第几页
    handleCurrentChange(val) {
      // 改变默认的页数
      this.start = val;
      // 切换页码时，要获取每页显示的条数
      this.queryInOut(this.PageSize, (this.start = val));
    },
  },
};
</script>
<style lang="scss" scoped>
.tables {
  float: left;
  width: 100%;
  height: auto;
  margin-top: 10px;
}
.tab {
  width: 30%;
  float: left;
  margin-bottom: 10px;
  margin-top: 10px;
}
.time {
  width: 70%;
  float: left;
  margin-bottom: 10px;
  margin-top: 10px;
}
.app-container {
    padding: 23
px

}
.Btn {
  float: right;
}
.paging {
  float: right;
  margin-top: 12px;
  margin-bottom: 30px;
}
@media screen and (min-width: 1200px) and (max-width: 1365px) {
  .tab {
    width: 50%;
    float: left;
    margin-bottom: 10px;
  }
  .time {
    width: 50%;
    float: left;
    margin-bottom: 10px;
  }
}
@media screen and (min-width: 1366px) and (max-width: 1600px) {
  .tab {
    width: 48%;
    float: left;
    margin-bottom: 20px;
  }
  .time {
    width: 41%;
    float: left;
    margin-right: 7%;
    margin-bottom: 20px;
  }
}
@media screen and (min-width: 1800px) {
  .tab {
    width: 50%;
    float: left;
    margin-bottom: 10px;
  }
  .time {
    width: 40%;
    float: left;
    margin-bottom: 10px;
  }
}
</style>
